<?php
class NetcontrolAction extends BaseAction
{
    public function index()
    {
        $output = array();
        //获取 mall 访问地址
        exec("awk '{print $1}'  /home/wwwlog/mall.log | sort | uniq -c | sort -nr | head -50", $output);
        if (empty($output)) {
            dump('没有日志记录');
            exit;
        }
        foreach ($output as $ip) {
            $ipCount = explode(' ', trim($ip));
            if (!strstr($ipCount[1], '192.168.1.')) {
                $ipDetail = $this->getIpDetail($ipCount[1]);
                //320100 南京 city_id
                if ($ipDetail['data']['city_id'] == '320100') {
                } else {
                    exec("sudo iptables -t filter -A INPUT -s " . $ipCount[1] . " -i eth0 -j DROP");
                }
            }
        }
    }
}

?>